package grimbo.goodwinfooty.server.mvc;

import grimbo.goodwinfooty.server.GoodwinFootyDB;
import grimbo.goodwinfooty.service.model.FootyMatrix;

import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 * Upgrade data. This version might add one-off payments.
 */
public class UpgradeDataController extends AbstractController {
	private static final String CNAME = UpgradeDataController.class.getName();
	private static final Logger log = Logger.getLogger(CNAME);

	private GoodwinFootyDB datastore;

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest req,
			HttpServletResponse res) throws Exception {
		FootyMatrix fm = datastore.loadFootyMatrix();
		datastore.saveFootyMatrix(fm);
		res.getWriter().print("success");
		return null;
	}

	public GoodwinFootyDB getDatastore() {
		return datastore;
	}

	public void setDatastore(GoodwinFootyDB datastore) {
		this.datastore = datastore;
	}
}
